import { api } from "../Axios";
import _ from "lodash";

export default {
  namespaced: true,
  name: 'userInfo',
  state: {
    "company_Employee_Id": 0,//员工Id
    "company_Department_Id": 0,//
    "company_Department_Company_Id": 0,//分公司id，好像是获取后续option的重要id
    "分公司名": '',
    "status": 0,//1？？
    "realName": "",//真实名字
    "employee_Name": "",//bsy？？
    "employee_Password": "",
    "company_Post_Id": 0,//职务=>等级,主要是{1:超级管理员,6:总经理,5:销售总监,4:销售经理,3:销售主任,2:销售员工}
    "currDayMaximum": 0,
    "qW_Department_Id": 0,
    "sortNumber": 0,
    "addTime": null,//2020-11-16 13:33:11？？
    "editTime": null,//2022-01-06 16:31:06？？,
    "wxqrCode": null,
    "deptName": null,
    "allMoney": 0,
    "sfMoney": 0,
    "orderNumber": 0,
    "oldpasswords": null,
    "postName": null,
    "agentNumber": null,
    "useRealName": null,
    "companyInfo": null,
    "eS_Company_Id": null,
    "qW_Department_Id_Service": 0,
    "qW_Department_Id_Service2": 0,
    "eS_Company_Id_Service": null,
    "practiceNumber": "",//1111111111111？？
    "teacher_Id": 0,
    "tradingStyle": null,
    "fromSource_Id": 0,
    "fromSourceIdList": null,
    "fromSource": null,
    "companyName": null,
    "types": 0,
    "entryTime": null,
    "entryTimeString": "",
    "departureTime": null,
    "departureTimeString": ""
  },
  mutations: {
    init: function (state, json) {
      _.forIn(json, (v, k, o) => {
        _.set(state, k, v)
      })
      return Promise.resolve(200)
    }
  },
  getters: {
    getUserInfo: function (state) {
      return state;
    },
    getEmployee: function (state) {
      return {
        company_Department_Company_Id: state.company_Department_Company_Id,
        company_Employee_Id: state.company_Employee_Id
      }
    },
    getIsLoading: function (state) {
      let lv = state.company_Post_Id;
      // { 1: 超级管理员, 6: 总经理, 5: 销售总监, 4: 销售经理, 3: 销售主任, 2: 销售员工 }
      return {
        departmen: ![2, 3].includes(lv),
        sales: ![2].includes(lv),
      }
    }

  },//调用时要用this.$store.getters['molle/getValue']
  actions: {},
}